package com.openrestaurant.exposure.resource;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import com.sun.jersey.spi.resource.Singleton;

@Path("/sample")
@Component
@Singleton
public class SampleResource {
	private String sampleText = "Default sample text!";
	private final Log log = LogFactory.getLog(SampleResource.class);

	@GET
	@Produces("text/plain")
	public String getSampleText() {
		log.trace("In get sample text");
		return sampleText;
	}

	@POST
	@Consumes("text/plain")
	@Produces("text/plain")
	public Response setSampleText(String incomingText) {
		log.trace("In set sample text");
		this.sampleText = incomingText;
		return Response.ok().build();
	}
}
